Skip to content

feat(native): Add toHaveProp#148

Merged
SbsCruz merged 51 commits intofeat/native-to-contain-elementfrom
feat/native-to-have-prop
Apr 2, 2026
Merged

feat(native): Add toHaveProp#148
SbsCruz merged 51 commits intofeat/native-to-contain-elementfrom
feat/native-to-have-prop

Conversation

@kdquistanchala
Copy link
Copy Markdown
Contributor

This PR adds the toHaveProp() matcher for React Native

@kdquistanchala kdquistanchala self-assigned this Apr 2, 2025
@kdquistanchala kdquistanchala added the enhancement New feature or request label Apr 2, 2025
* @returns the assertion instance
*/
public toHaveProp(propName: string, value?: unknown): this {
const propValue: unknown = get(this.actual, `props.${propName}`, undefined);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as for my understanding, why are we using uknown instead of undefined or any in here?

const invertedErrorMessage = value === undefined
? `Expected element ${this.toString()} NOT to have prop '${propName}'.`
: `Expected element ${this.toString()} NOT to have prop '${propName}' with value '${String(value)}'.`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding to the error message something like: Verify the element properties?

@lopenchi lopenchi force-pushed the feat/native-to-contain-element branch 2 times, most recently from 4194055 to 392d9c6 Compare July 14, 2025 21:43
@lopenchi lopenchi force-pushed the feat/native-to-contain-element branch from 560250d to a560a05 Compare July 22, 2025 21:48
ACR1209 and others added 8 commits March 24, 2026 11:49
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Carolina López <lopenchii@gmail.com>
Co-authored-by: Jose Luis Leon <joseluis5000l@gmail.com>
Co-authored-by: Carolina Lopez <calopez@twilio.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@SbsCruz SbsCruz marked this pull request as ready for review April 1, 2026 21:21
@SbsCruz SbsCruz requested review from JDOM10 and suany0805 April 1, 2026 21:21
Copy link
Copy Markdown
Collaborator

@JDOM10 JDOM10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@SbsCruz SbsCruz merged commit 8fad8ba into feat/native-to-contain-element Apr 2, 2026
4 checks passed
@SbsCruz SbsCruz deleted the feat/native-to-have-prop branch April 2, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants